$(document).ready(function () {
    dzzl.onload();
})
var dzzl = (function () {
    return {
        onload : function () {
            dzzl.tableData();
            dzzl.delAllBtn();
            dzzl.alertBox();
            // dzzl.alertBox1();
            // dzzl.clearBox();
        },
       /*表格数据交互*/
      tableData: function() {
 		var data = [{
 				"number": "01",
 				"filename": "税务登记正本",
 				"uploaddate": "2018-08-23",
 				"state":"已审核",
 				"operation": null
 			},
 			{
 				"number": "02",
 				"filename": "税务登记正本",
 				"uploaddate": "2018-08-23",
 				"state":"已审核",
 				"operation": null
 			},
 			{
 				"number": "03",
 				"filename": "税务登记正本",
 				"uploaddate": "2018-08-23",
 				"state":"未审核",
 				"operation": null
 			},
 			{
 				"number": "04",
 				"filename": "税务登记正本",
 				"uploaddate": "2018-08-23",
 				"state":"已审核",
 				"operation": null
 			}
 		];
 		$('#wepQyglyrz').DataTable({
 			"data": data,
 			"columnDefs": [{
 					"targets": -1,
 					"data": null,
 					"render": function(data, type, full, meta) {
 						return '<a href="#"><span class="btn wxl_bg_lan1">查看</span></a><a href="#"><span class="btn wxl_bg_red">删除</span></a>'
 					}
 				},
 				{
 					'targets': 0,
 					'className': 'dt-body-center',
 					'render': function(data, type, row) {
 						return '<input class="checkchild" type="checkbox"/>';
 					}
 				}
 			],
 			"columns": [
 			    {
 					"data": "btn"
 				},
 			    {
 					"data": "number"
 				},
 				{
 					"data": "filename"
 				},
 				{
 					"data": "uploaddate"
 				},
 				{
 					"data": "state"
 				},
 				{
 					"data": "operation"
 				}
 			],
// 			"paging": false,
 			"info": false,
 			"ordering": false,
 			"lengthChange": false,
 			"searching": false,
 			"fnInitComplete": function (oSettings, json) {/*判断认证状态显示字体颜色*/
	            for(var i=0;i<$('#wepQyglyrz tbody tr').length;i++){
	            	if($('#wepQyglyrz tbody tr').eq(i).find('td').eq(4).text() == "已审核"){
	            		$('#wepQyglyrz tbody tr').eq(i).find('td').eq(4).addClass('ycl')
	            	}else{
	            		$('#wepQyglyrz tbody tr').eq(i).find('td').eq(4).addClass('wcl')
	            	}
	            };
              $('.wxl_bg_lan1').parent().on('click',function(){
               parent.yhzx.alertBox1('.bodyNode');
              });
	        }
 		});
      },
        /*点击增加弹出框*/
     alertBox:function(){
     	$('.wep_rz_add').on('click',function(){
			var html1 = $('.wep_alert_icon').html();
     		$(window.parent.document).find('.wep_dzzl_addBox').html(html1);
     		parent.yhzx.alertBox('.wep_dzzl_addBox','900px','auto');
     		parent.yhzx.imgUploadF();
     	})
     },
	/*点击删除、取消认证*/
   	  delAllBtn:function(){
   		$('.wep_rz_del').on('click',function(){
   			parent.yhzx.delAll("确定要删除吗？");
   		});
   	  },
      // 当弹出框关闭时，清空uploader内容。当前页面打开时就执行了
      // clearBox:function () {
      //   console.log(1);
      //   parent.yhzx.closeBox();
      // }
      // alertBox1:function(){
          // $('.wxl_bg_lan1').on('click',function(){
          //  parent.yhzx.alertBox1('.bodyNode');
          // });
      // },
    }
})();